import urllib2
import urllib
import bz2

cl=''
nothing='12345'
while True:
    req=urllib2.urlopen('http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=%s'%nothing)
    c=req.info().getheaders('Set-Cookie')[0].split(';')[0].split('=')[1]
    print 'c is(',c,')'
    cl+=c
    s=req.read()
    print s
    nothing = re.search('busynothing is (?P<nothing>\d+)',s).group('nothing')
    print nothing

print bz2.decompress(urllib.unquote_plus(cl))    
